package com.lexed.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lexed.pojo.Emp;
import com.lexed.service.EmpService;
import com.lexed.util.Util;

/**
 * Servlet implementation class SelectAll
 */
public class SelectAll extends HttpServlet {
	
	private EmpService empService = new EmpService();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			
			List<Emp> emps = empService.selectAll();
			
			String jsonString = Util.getTableJSONString(emps);
			
			response.setContentType("Application/json;charset=utf-8");
			response.getWriter().println(jsonString);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
